<template>
    <div class="Login">
        <div class="page-field">
            <div class="page-part">
                <mt-field  placeholder="请输入手机号" v-model="tel" type="tel"></mt-field>
                <mt-field  placeholder="请输入密码" v-model="password" type="password"></mt-field>
            </div>
            <mt-button type="primary" size="large" @click="login">login</mt-button>
            <!--<mt-button type="primary" size="large" @click="islogin">islogin</mt-button>-->
        </div>
    </div>
</template>

<script>
    import {
            login,
            loading,
            islogin
    } from '../common/api/api';
    import { Toast ,Indicator} from 'mint-ui';

  export default {
      name: 'Login',
      data () {
          return {
              articles:[],
              tel : null,
              password : null,
              createDialog: {
                  opened: false,
                  loading: false
              },
          }
      },
      components: {
          //Hello
      },
      methods: {
          login: function () {
              var vm = this;
              const params = {
                  mobile : vm.tel,
                  password : vm.password
              }
              loading(true);
              login(params, {
                  target: vm.createDialog
              })
              .then((data) => {
                  console.log(data);
                  vm.createDialog.opened = false;
                  if(data.errno == 0){
                      loading(false);
                      Toast('登陆成功');
                      this.$router.push('/home');
                  }else{
                      loading(false);
                      Toast(data.errmsg);
                  }

//                  vm.$router.push({
//                      name: "UserOrder",
//                      params: { handleId: 1 }
//                  });
              });
          },
          islogin: function () {
              var vm = this;
              const params = {
                  mobile : vm.tel,
                  password : vm.password
              }
              loading(true);
              islogin(params, {
                  target: vm.createDialog
              })
                      .then((data) => {
                          console.log(data);
                          vm.createDialog.opened = false;
                          loading(false);
                          Toast('登陆成功');
                          this.$router.push('/home');
//                  vm.$router.push({
//                      name: "UserOrder",
//                      params: { handleId: 1 }
//                  });
                      });
          }
      }
  }
</script>
